package com.sun.controller;

import com.sun.pojo.Admin;
import com.sun.service.impl.AdminServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author 烛龙神
 * @Description TODO
 * @date 2021-04-11 15:54
 */
@Controller
public class AdminController {

    @Autowired
    private AdminServiceImpl adminService;

    //登录页面
    @RequestMapping("/login")
    public String login()
    {
        return "login";
    }

    @RequestMapping("/doLogin")
    public String doLogin(String name, String password, Model model)
    {
        Admin admin = adminService.AdminLogin(name,password);
        if(admin == null)
        {
            model.addAttribute("msg","用户名或者密码不正确，请重新登录!!!");
            return "login";
        } else {
            return "redirect:/allBook";

        }


    }
}
